import img from '../images/img.png'
import imgA from '../images/imgA.png'
import img1 from '../images/img1.png'
import img1A from '../images/img1A.png'
import img2 from '../images/img2.png'
import img2A from '../images/img2A.png'
import img3 from '../images/img3.png'
import img3A from '../images/img3A.png'
import img4 from '../images/img4.png'
import img4A from '../images/img4A.png'
const defaultData = () => ({
  // 地图加载
  mapLoading: false,
  mapStyle: 'wx',
  componentsVisible: {
    xm: false,
    fwq: true,
    showLineName: true,
    showCamera: true
  },
  timeIndex: 0,
  timeList: [],
  timeText: [],
  damageColor: [
    'rgb(20,172,228)',
    'rgb(100,186,48)',
    'rgb(236,251,4)',
    'rgb(248,163,43)',
    'rgb(207,1,25)'
  ],
  hoverDamageColor: [
    'rgb(20,172,228)',
    'rgb(100,186,48)',
    'rgb(236,251,4)',
    'rgb(248,163,43)',
    'rgb(207,1,25)'
  ],
  snowColor: ['#cccccc', '#a0a0a0', '#6e6e6e', '#434442', '#7146dc', '#4a0170'],
  currentTab: 'lineDanger',
  lineList: [],
  tabList: [
    {
      name: '路面危险等级',
      type: 'old',
      imgA: imgA,
      img: img,
      key: 'lineDanger',
      flag: 'lineDanger',
      icon: 'icon-zhuyi',
      levels: ['低风险', '较低风险', '较高风险', '高风险', '极高风险'],
      color: [
        'rgb(20,172,228)',
        'rgb(100,186,48)',
        'rgb(236,251,4)',
        'rgb(248,163,43)',
        'rgb(207,1,25)'
      ]
    },
    {
      name: '视觉能见度',
      type: 'old',
      imgA: img1A,
      img: img1,
      key: 'visibility',
      flag: 'visibility',
      icon: 'icon-yanjing',
      levels: ['较好', '一般', '较差', '很差', '非常差'],
      color: [
        'rgb(20,172,228)',
        'rgb(100,186,48)',
        'rgb(236,251,4)',
        'rgb(248,163,43)',
        'rgb(207,1,25)'
      ]
    },
    // {
    //   name: '路面温度',
    //   type: 'old',
    //   imgA: img2A,
    //   img: img2,
    //   key: 'tem',
    //   flag: 'tem',
    //   icon: 'icon-daolu-mian',
    //   levels: ['0-10', '<10,10-30', '30-50', '-10-0,50-60', '60-70'],
    //   color: [
    //     'rgb(20,172,228)',
    //     'rgb(100,186,48)',
    //     'rgb(236,251,4)',
    //     'rgb(248,163,43)',
    //     'rgb(207,1,25)'
    //   ]
    // },
    // {
    //   name: '道路结冰',
    //   type: 'old',
    //   imgA: imgA,
    //   img: img,
    //   key: 'freez',
    //   flag: 'freez',
    //   icon: 'icon-daolujiebing',
    //   levels: ['无结冰', '蓝色预警', '黄色预警', '橙色预警', '红色预警'],
    //   color: ['rgb(20,172,228)', 'rgb(100,186,48)', 'rgb(236,251,4)', 'rgb(248,163,43)', 'rgb(207,1,25)']
    // },
    {
      name: '降水强度',
      type: 'old',
      imgA: img3A,
      img: img3,
      key: 'rain',
      flag: 'rain',
      icon: 'icon-jiangshui1',
      levels: ['无影响', '小雪', '中雪', '大雪', '暴雪'],
      color: [
        'rgb(20,172,228)',
        'rgb(100,186,48)',
        'rgb(236,251,4)',
        'rgb(248,163,43)',
        'rgb(207,1,25)'
      ]
    },
    {
      name: '风力风向',
      type: 'old',
      key: 'wind',
      imgA: img4A,
      img: img4,
      flag: 'wind',
      icon: 'icon-fengsu',
      levels: ['2级以下', '3-4级', '5级', '6-7级', '8级以上'],
      color: [
        'rgb(20,172,228)',
        'rgb(100,186,48)',
        'rgb(236,251,4)',
        'rgb(248,163,43)',
        'rgb(207,1,25)'
      ]
    }
  ],
  pointType: [],
  pointTypeList: [
    {
      name: '服务区',
      key: 'fwq',
      id: 0,
      icon: 'icon-fuwuqu'
    },
    {
      name: '横风区',
      key: 'hfq',
      id: 6,
      icon: 'icon-hengfengqu'
    },
    {
      name: '隧道',
      key: 'sd',
      id: 7,
      icon: 'icon-suidao'
    },
    {
      name: '大桥',
      key: 'dq',
      id: 8,
      icon: 'icon-daqiao'
    },
    {
      name: '急转弯',
      key: 'jzw',
      id: 9,
      icon: 'icon-jizhuanwan'
    },
    {
      name: '上坡',
      key: 'sp',
      id: 10,
      icon: 'icon-shangpo'
    },
    {
      name: '下坡',
      key: 'sp',
      id: 11,
      icon: 'icon-xiapo'
    },
    {
      name: '事故易发点',
      key: 'sgyfd',
      id: 12,
      icon: 'icon-shiguyifadian'
    }
  ],
  // 高速公路 铁路
  showType: []
})

export const useTrafficStore = defineStore({
  id: 'traffic',
  state: () => {
    return defaultData()
  },
  getters: {
    currentTabData: state => {
      return state.tabList.find(i => i.key === state.currentTab)
    }
  },
  actions: {
    // 销毁 并初始化数据
    handleUnmountedInitData() {
      const defaultDataObj = defaultData()
      Object.keys(defaultDataObj).forEach(item => {
        this[item] = defaultDataObj[item]
      })
    }
  }
})
